using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ddlSPT.DataSource = getServiceProviderTypes();
            ddlSPT.DataBind();
            ddlSPT.Items.Add(new ListItem("~ Select SPT ~", "0"));
            ddlSPT.SelectedValue = "0";
        }
    }
    protected void btnPoolSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect("PoolEdt.aspx?PoolName=" + txtPoolName.Text);
    }
    protected void btnSPSearch_Click(object sender, EventArgs e)
    {
        string spt;
        if (ddlSPT.SelectedValue == "0")
            spt = string.Empty;
        else
            spt = ddlSPT.SelectedValue;

        Response.Redirect("ServiceProviderEdt.aspx?SPName=" + txtSPName.Text + "&SPType=" + spt);
    }
    protected void btnSPTSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceProviderTypeEdt.aspx?SPTName=" + txtSPTName.Text + "&SPTCode=" + txtSPTCode.Text);
    }
    protected void btnMTSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect("MessageTypeEdt.aspx?MTName=" + txtMTName.Text + "&MTVersion=" + txtMTVersion.Text);
    }
    protected void btnPoolAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("PoolEdt.aspx?Add=y");
    }
    protected void btnSPAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceProviderAdd.aspx");
    }
    protected void btnSPTAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("ServiceProviderTypeEdt.aspx?Add=y");
    }
    protected void btnMTAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("MessageTypeEdt.aspx?Add=y");
    }

    private AdminServices.ServiceProviderType[] getServiceProviderTypes()
    {

        AdminServices.AdminServices proxy = new AdminServices.AdminServices();
        AdminServices.ServiceProviderTypeSearchRequest serviceProviderTypeSearchRequest = new AdminServices.ServiceProviderTypeSearchRequest();
        serviceProviderTypeSearchRequest.InPool = true;
        return proxy.ServiceProviderTypeSearch(proxy.ValidateUser("me", "!password01"), serviceProviderTypeSearchRequest);
    }
    
}
